<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>定时任务运行日志</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layui/css/layui.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<table class="layui-hide" id="quartz" lay-filter="quartz"></table>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <span class="layui-btn layui-btn-sm">${jobKey}任务运行日志一览表</span>
    </div>
</script>


<script src="/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    /* 时间戳转化开始 */
    Date.prototype.format = function (fmt) { //author: meizz  
        var o = {
            "M+": this.getMonth() + 1, //月份  
            "d+": this.getDate(), //日  
            "h+": this.getHours(), //小时  
            "m+": this.getMinutes(), //分  
            "s+": this.getSeconds(), //秒   
            "q+": Math.floor((this.getMonth() + 3) / 3),    //q是季度
            "S": this.getMilliseconds() //毫秒  
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }
</script>
<script>
    layui.use(['jquery', 'table'], function(){
        var table = layui.table;
        var form = layui.form;

        var tableRender = table.render({
            elem: '#quartz'
            ,url:'./listLogs?key=${jobKey}&xAuthToken=${xAuthToken}'
            ,toolbar: '#toolbarDemo'
            ,title: ''
            ,cols: [[
                {field:'jobName', title:'任务ID', width: 300}
                ,{field:'created', title:'运行开始时间', width: 200, templet: function(res){
                        var date = new Date();
                        date.setTime(res.created);
                        return date.format("yyyy-MM-dd hh:mm:ss");
                 }}
                ,{field:'spendTime', title:'执行时间(单位秒)', width:150}
                ,{field:'runningState', title:'是否成功运行', width:150, templet: function(res){
                        if(res.runningState==null||typeof(res.runningState) == undefined) return '';
                        return res.runningState ? '成功' : '失败';
                }}
                ,{field:'errorMsg', title:'错误日志'}
            ]]
            ,page: true
        });

    });
</script>

</body>
</html>